import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '部门',
    align:"center",
    dataIndex: 'departmentId_dictText'
   },
   {
    title: '规则名称',
    align:"center",
    dataIndex: 'ruleName'
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'status',
    customRender:({text}) => {
        return  render.renderDict(text, 'attRuleStatus');
    },
   },
   {
    title: '创建人',
    align:"center",
    dataIndex: 'createBy'
   },
   {
    title: '创建时间',
    align:"center",
    dataIndex: 'createTime'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
      label: "规则",
      field: 'attRuleId',
      component: 'JSearchSelect',
      slot: 'ruleSlot',
      // componentProps:{
      //    dict:"att_rule,rule_name,id"
      // }
      //colProps: {span: 6},
  },
  {
    field: 'departmentId',
    component: 'Input',
    label: "",
    slot:'depId',
    //colProps: {span: 6},
 },

];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '规则',
    field: 'attRuleId',
    component: 'JSearchSelect',
    slot: 'ruleSlot',
    componentProps:{
       dict:"att_rule,rule_name,id",
      //  otherParams: {
      //   rule_name:111
      //  },
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入规则!'},
          ];
     },
  },
  {
    label: '部门',
    field: 'departmentId',
    component: 'JSelectDept',
    componentProps:{
      checkStrictly: true,
      multiple:false
    }
  },
  {
    label: '状态',
    field: 'status',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"attRuleStatus"
     },
     show:false,
    defaultValue:'1',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入状态!'},
          ];
     },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  attRuleId: {title: '规则id',order: 0,view: 'number', type: 'number'},
  departmentId: {title: '部门id',order: 1,view: 'sel_depart', type: 'string'},
  status: {title: '状态',order: 2,view: 'list', type: 'string'},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
